﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HFController;

namespace HFWebManage.Ad
{
    public partial class AdList : HFController.BagePages
    {
        /// <summary>
        /// 列表
        /// </summary>
        public List<hf.Model.Ad> list = new List<hf.Model.Ad>();

        protected void Page_Load(object sender, EventArgs e)
        {
            string PageStr = "";
            list = AdController.getController().getAdList(out PageStr);
            pager.Text = PageStr;

            string Action = this.GetQuery("action");
            switch (Action)
            {
                case "delete": //单个删除
                    int ID = int.Parse(this.GetQuery("ID"));
                    AdController.getController().doDelegeAd(ID);
                    break;
                case "deleteall": //批量删除
                    string IDS = this.GetAll("cid1");
                    AdController.getController().doDelegeAd(IDS.Split(','));
                    break;
            }
        }
        /// <summary>
        /// 获取广告分类名称
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public string getAdClassName(int ID)
        {
            hf.Model.AdClass model = AdController.getController().getAdClassModel(ID);
            //return model.AdClassName;
            if (model != null)
            {
                return model.AdClassName;
            }
            else
            {
                return "";
            }
        }
    }
}